package com.dasberg.gwt.client;

import com.google.gwt.user.client.rpc.AsyncCallback;


/**
 * Authentication Service Async.
 * @author mischa
 */
public interface AuthenticationServiceAsync {
    /**
     * Authenticate with the given username and password.
     * @param username The username.
     * @param password The password.
     * @param async De async callback.
     * @return <code>true</code> if the system can authenticate with the given username and password,
     *         else <code>false</code>.
     */
    void authenticate(String username, String password, AsyncCallback<Boolean> async);

    /**
     * Deauthenticate by removing the AuthenticationToken from the session.
     * @param async De async callback.
     */
    void deauthenticate(AsyncCallback<Void> async);

    /**
     * Indicates if a user has the given role assigned.
     * @param role The role.
     * @param async De async callback.
     * @return <code>true</code> if the user has the given role assigned, else <code>false</code>.
     */
    void isInRole(String role, AsyncCallback<Boolean> async);

    /**
     * Indicates if the user is authenticated.
     * @param async De async callback.
     * @return <code>true</code> if the user is authenticated, else <code>false</code>.
     */
    void isAuthenticated(AsyncCallback<Boolean> async);

    /**
     * Gets the authenticated user.
     * @param async De async callback.
     * @return user The user.
     */
    void getAuthenticatedUser(AsyncCallback<String> async);
}